<%@ page contentType="text/html; charset=utf-8" language="java" import="java.sql.*" errorPage="" %>
<%@ include file="/WEB-INF/common/common.jsp"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
	<head>
		<meta charset="utf-8" />
		<title>支付</title>
		<meta name="description" content="壁虎学车" />
		<meta name="keywords" content="壁虎学车"/>
		<meta name="viewport" content="initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
		<link rel="stylesheet" href="<%=path %>/BihuWeb/css/amazeui.min.css" />
		<link rel="stylesheet" href="<%=path %>/BihuWeb/css/style.css" />
		<script type="text/javascript" src="<%=path %>/BihuWeb/js/jquery.min.js" ></script>
		<script type="text/javascript" src="<%=path %>/BihuWeb/js/amazeui.min.js" ></script>
        <script type="text/javascript">
        //使用jsapi接口，获取到code
        $jsApi = new JsApi_pub();
        //=========步骤1：网页授权获取用户openid============
        //通过code获得openid
        if (!isset($_GET['code']))
        {
            //触发微信返回code码
            $url = $jsApi->createOauthUrlForCode(WxPayConf_pub::JS_API_CALL_URL);
            Header("Location: $url"); 
        }else
        {
            //获取code码，以获取openid
            $code = $_GET['code'];
            $jsApi->setCode($code);
            $openid = $jsApi->getOpenId();
			alert('$openid='+$openid);
        }
		</script>       
        
		<script type="text/javascript">
		function onBridgeReady(){
		var appId = "${sessionScope.appId}";//"${payMap.appId}";
		var timeStamp = "${sessionScope.timeStamp}";
		var nonceStr = "${sessionScope.nonceStr}";
		var package = "${sessionScope.packages}"; 
		var paySign = "${sessionScope.paySign}";
		var url = "<%=basePath%>/User_myMerchandise.action";
    WeixinJSBridge.invoke(
        'getBrandWCPayRequest', {
            "appId":appId,     //公众号名称，由商户传入     
            "timeStamp":timeStamp,         //时间戳，自1970年以来的秒数     
            "nonceStr":nonceStr, //随机串     
            "package":package,     
            "signType":"MD5",         //微信签名方式：     
            "paySign":paySign //微信签名 
        },
        function(res){     
            if(res.err_msg == "get_brand_wcpay_request:ok" ) {
             window.location.replace(url);
            
            }     // 使用以上方式判断前端返回,微信团队郑重提示：res.err_msg将在用户支付成功后返回    ok，但并不保证它绝对可靠。 
        }
    ); 
 }
if (typeof WeixinJSBridge == "undefined"){
    if( document.addEventListener ){
        document.addEventListener('WeixinJSBridgeReady', onBridgeReady, false);
    }else if (document.attachEvent){
        document.attachEvent('WeixinJSBridgeReady', onBridgeReady); 
        document.attachEvent('onWeixinJSBridgeReady', onBridgeReady);
    }
 }else{
    onBridgeReady();
 } 
		
		
		</script>
	</head>
	<body>
	<!-- 
    	<header data-am-widget="header" class="am-header am-header-default header">

		  <h1 class="am-header-title"> <a href="#title-link" class="" style="color: #333;">${sysUnit.schoolName }</a></h1>
		
	  </header>
		
		  <div data-am-widget="intro" class="am-intro am-cf am-intro-default">
		    <div class="am-intro-hd">
		        <h2 class="am-intro-title">订单详情</h2>
		    </div>
		    <div class="am-g am-intro-bd">
		    	<div class="content">
			        
			        	<p>需支付：${serviceMerchandiseOrder.orderRealPrice }</p>
			        	<p>原价：${serviceMerchandiseOrder.orderPrice }</p>
			        	<p>支付方式：<c:choose>
			        	<c:when test="${1 == serviceMerchandiseOrder.orderPayWay }">支付定金</c:when>
			        	<c:when test="${2 == serviceMerchandiseOrder.orderPayWay }">微信支付</c:when>
			        	<c:when test="${3 == serviceMerchandiseOrder.orderPayWay }">花呗支付</c:when>
			        	</c:choose> </p>
                        <p>学员姓名：${serviceMerchandiseOrder.stuName }</p>
                        <p>学员手机号码：${serviceMerchandiseOrder.stuPhone }</p>
                        <p>下单时间：${serviceMerchandiseOrder.orderStartTime }</p>
			        	
			        	
			      </div> 
		      
		    </div>
		   
		   
		   
		   
		  </div>
		  <div class="search-input">
		   
		   <input type="button" value="支付" onclick="onBridgeReady()"/>
		   </div>
		  <div class="h50"></div>
		
		 -->
		 <p class="detail text">请尽快完成支付</p>
	</body>
</html>
